package com.example.anote;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;

public class EditActivity extends Activity {
	int id,stat;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_edit);
		setTitle("Edition");
		
		EditText titre = (EditText)findViewById(R.id.titreedit);
		titre.setText(StaticStore.NoteStore.getTitre());
		
		EditText desc = (EditText)findViewById(R.id.descredit);
		desc.setText(StaticStore.NoteStore.getDescription());
		
		SeekBar bar = (SeekBar)findViewById(R.id.seekBaredit);
		bar.setProgress(StaticStore.NoteStore.getProgress());
		
		id = StaticStore.NoteStore.getId();
		stat = StaticStore.NoteStore.getStat();
	
	
	final ImageButton saveButton = (ImageButton) findViewById(R.id.saveedit);
	saveButton.setOnClickListener(new View.OnClickListener() {
                    
    @Override
    public void onClick(View v) {

    	TextView txt = (TextView) EditActivity.this.findViewById(R.id.titreedit);
    	ProgressBar proc = (ProgressBar) EditActivity.this.findViewById(R.id.seekBaredit);
    	TextView desc = (TextView) EditActivity.this.findViewById(R.id.descredit);
    	
    	StaticStore.NoteStore = new NoteList(id, txt.getText().toString(), desc.getText().toString(), proc.getProgress(),stat);
		
		setResult(1);
		EditActivity.this.finish();
    	
    }
    	});
	
	
	}
	
	

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.edit, menu);
		return true;
	}

}
